package com.pet_service.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.pet_service.util.CustomDateTimeSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * @author 邹全伸
 * @version 1.0
 * @date 2025-09-18 08:36
 */
@Data
public class BaseEntity implements Serializable {

    @Schema(description = "主键")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;


    @Schema(description = "创建时间")
    @JsonSerialize(using = CustomDateTimeSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")//因为时区差，所以要加上8时区
    @TableField(value = "created_at")
    private Date created_at;

    @Schema(description = "更新时间")
    // 告诉json序列化器，将Date对象转换为字符串时，按照指定的格式进行转换。
    @JsonSerialize(using = CustomDateTimeSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @TableField(value = "updated_at")
    private Date updated_at;


    @Schema(description = "逻辑删除")//物理删除是将数据从表中删除，逻辑删除是将数据标记为删除状态，数据依然存在。
    @TableField("is_deleted")
    @TableLogic(value = "0", delval = "1") // 未删除=0，已删除=1
    private Integer is_deleted;

}
